package cn.edu.scau.cmi.yangjiamin.springhibernate;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;


public class ApplicationContextUtil {

	private static ApplicationContext ac;

	public static ApplicationContext getApplicationContext() {
		if (ac == null) {
			ac = new ClassPathXmlApplicationContext(
					new String[] { "cn/edu/scau/cmi/yangjiamin/springhibernate/applicationContext.xml" });
		}
		return ac;
	}

	public static StudentDao getStudentDao() {
		return (StudentDao) getApplicationContext().getBean("StudentDao");
	}

	public static TeacherDao getTeacherDao() {
		return (TeacherDao) getApplicationContext().getBean("TeacherDao");
	}

	
}
